Why this topic

I have recentely been experiencing an array of emotions due to school starting, leaving home and saying goodby to people, seeing my school friends again. As a result, I am very susceptible to the level of emotions in the music i listen to.

I wanted to see if there is a way to determine which genre of songs will keep me at a constant mood(whether happy or sad) and which songs will take me on even more of an emotional rollercoaster.

Step 1: Loading all the necessary library files to create Data Story

This notebook runs R in python using reticulate, so we need to install reticulate first. Then we install all the necessary python packages for the assignment. The code has been ommitted for the sake of presentation The packages used were: * nltk(Python NLP library) * pandas * wordcloud * matplotlib

Step 2: Read in the data preprocess them

In this part, I parsed the lyrics using various python nltk methods all of which are commented in the code. The result was a dataframe on which analysis can be performed

Preprocessing steps:
  • tokenization using word_tokenize
  • removing stopwords
  • changing tokens to lowercase

Step 3: What words are associated with each genre of music

I wanted to see whether the most frequent words in a genre would allow us to establish what song is the most emotive.

Word cloud for Jazz music
## (-0.5, 399.5, 199.5, -0.5)

##### Word cloud for Pop music

## (-0.5, 399.5, 199.5, -0.5)

Word cloud for Hip-Hop
## (-0.5, 399.5, 199.5, -0.5)

Step 4: Check the trend in the happiness levels of the songs over the years

Because the wordclouds are ovwerwhelmed by the most frequant song words like “love”, I decided to use sentiment analysis to determine the positivity or negativity of a song.

I also wanted to take time into account and answer the question: have some genres become more happy over the years while others became more grim? Below is some of the output.All the songs maximum happiness has been plotted on the same graph

The Scores shown were obtained by: getting the max polarity score(swhat is the highest score gitten by a line in the song) per song and just averaging those per genre.

Observations

  • We see that Metal music is overall negative in comparision to other genres. But Metal now is more neutral than dark
  • Most other genres seem to remain at the same maximum happiness level.
  • There are less fluctuations in average happiness per genre from the beginning of the 21st century

This doesn’t really tell you what to listen to based on your mood because they have relatively similar positivity levels

Step 5: Check the difference between the maximum and minimum happiness in different genres over the years

So I decided to delve further into this theme of emotiveness to see which genres can be considered as having the largest range of emotions expressed. The graphs below show both the max polarity of the song by genre and the min polarity over the years for a couple of genres.

The bigger the difference, the larger the range of emotions a song’s lines display(large difference between most happy line and most sad line)

Other fun observations from above:

All genres seemed to take a dip in terms of their happiness score at the turn of the millenium. This would be an interesting angle to investigate given other data like economic data and news data.But after 2000 most songs seem to have constant levels of happiness scores

Final Determination

We see especially from the last set of graphs that the most emotive genre is Hip-Hop. You should listen to this when you are not feeling too many emotions at once so that the songs don’t take you on a ride.

If however, you are experiencing a range of emotions at once and you want something consistent, the data recommends listening to R&B. I know right! Surprising! But I didn’t say quiet, I just said least range of emotions. The song will either be really sad or really happy.